<!-- Content Bar Header -->
<?php
$auth = Auth::getAuth('current_user');
$db = new Database();

if ($auth['user_level_id'] == "2") {
    echo $this->setInclude("contentHeader", null, null, null);
}
?>
<div class="content_wrapper">
    <div class="mainContent">
        <div>
            <div class="widget">
                <div class="head">
                    <div class="title_head">
                        <i class="icon-bar-chart"></i> List of Reports
                    </div>
                    <div class="pull-right" style="margin:5px;">
                        <input type="text" class="input-search search-report-value" placeholder="Search">
                    </div>
                </div>
                <div class="report-list-wrapper">
                    <?php
//                    if ($auth['user_level_id'] != '1') {
//                        $reports = functions::getReports("WHERE company_id={$db->escape($auth['company_id'])} LIMIT 0,10");
//                    } else {
                    $reports = functions::getReports("WHERE company_id={$db->escape($auth['company_id'])} LIMIT 0,10");
                    // }


                    if (count($reports) == 0) {
                        ?>
                        <div class="notification_wrapper" style="height:auto">
                            <div class="wrong" style="width:98.5%">
                                <div class="padding_5">
                                    <img src="/images/warning/wrong.png" width="22" height="19" class="img-notification-position">
                                    <div class="notification-position">No Record Found</div>
                                </div>
                            </div>
                        </div>
                        <?php
                    }
                    foreach ($reports as $reportDoc) {

                        $ret .= '<div class="hr"></div>';
                        $ret .= '<div class="supTicket nobg">';
                        $ret .= '<div class="issueType">';
                        $ret .= '<span class="issueInfo">' . $reportDoc->title . '</span>';
                        $ret .= '<span class="issueNum">';

                        if ($reportDoc->is_active == 1) {
                            $ret .= '<a class="tip cursor" data-original-title="Generate ' . $reportDoc->title . '" data-placement="top" id="" link-type="report-generation" data-report-id="' . $reportDoc->id . '"><button class="btn-basicBtn padding_5 cursor"><i class="icon-edit" ></i></button></a> ';
                        }

                        if ($auth['user_level_id'] == "2") {
                            $ret .= '<a href="/report?id=' . $reportDoc->id . '&form_id=' . $reportDoc->form_id . '" class="tip cursor" data-original-title="Edit ' . $reportDoc->title . '" data-placement="top" id="" data-orgchart-id=""><button class="btn-basicBtn padding_5 cursor"><i class="icon-edit" ></i></button></a> ';
                            $ret .= '<a class="tip cursor update_status_report" data-original-title="' . functions::getStatus_revert($reportDoc->is_active) . '" data-status="' . $reportDoc->is_active . '" data-placement="top" id="" data-id="' . $reportDoc->id . '"><button class="btn-basicBtn padding_5 cursor"><i class="icon-globe"></i></button></a>';
                        }

                        $ret .= '</span>';

                        $ret .= '</div>';

                        $ret .= '<div class="issueSummary">';
                        $ret .= '<a href="#" title="" class="pull-left"><i style="height:30px; width:30px;font-size:30px;color: #676767;" class="icon-bar-chart"></i></a>';
                        $ret .= '<div class="ticketInfo">';
                        $ret .= '<ul>';
                        $ret .= '<li><a href="/report?id=' . $reportDoc->id . '&form_id=' . $reportDoc->form_id . '" title="">' . $reportDoc->title . '</a></li>';
                        $ret .= '<li class="even"><strong class="red">[ Report ]</strong></li>';
                        $ret .= '<li>Status: <strong class="green">[ ' . functions::getStatus($reportDoc->is_active) . ' ]</strong></li>';
                        $ret .= '<li class="even">' . $reportDoc->date_created . '</li>';
                        $ret .= '</ul>';
                        $ret .= '</div>';
                        $ret .= '</div>';
                        $ret .= '</div>';
                        $ret .= '<div class="hr"></div>';
                    }
                    echo $ret;
                    ?>
                </div>
            </div>
        </div>
    </div>
    <input type="text" class="userLevel display2" value="<?php echo $auth['user_level_id']; ?>">
    <?php
// Company Announcement
    echo $this->setInclude("company_announcement", null, null, null);

// Starred
    echo $this->setInclude("starred", null, null, null);

// My Request
    echo $this->setInclude("my_request", null, null, null);
    ?>
</div>
<script type="text/javascript" src="/js/functions/search.js"></script>